
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>ES评分是怎么计算的？ - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>ES评分是怎么计算的？ - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">Elasticsearch（ES）的文档相关性评分主要基于哪两种核心算法？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Elasticsearch的评分计算是基于 TF-IDF 和 BM25 算法的，具体取决于使用的相似度算法。评分用于衡量文档与查询的相关性并对结果进行排序。</div>
          </div>
          <div class="card-source">来源: 文档开头介绍部分</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">在TF-IDF算法中，TF（词频）和IDF（逆文档频率）各自的定义和作用是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">TF（Term Frequency，词频）用于衡量一个词在单个文档中的出现频率。IDF（Inverse Document Frequency，逆文档频率）则用于衡量该词在整个文档集合中的重要性。</div>
          </div>
          <div class="card-source">来源: 1. TF-IDF 算法</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">什么是BM25算法？它通常在哪个版本的Elasticsearch中被广泛使用？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">BM25（Best Match 25）是一种改进的评分函数，是Okapi BM模型的一个变体。它考虑了词频和文档长度的规范化，常用于Elasticsearch 7.x及以后的版本。</div>
          </div>
          <div class="card-source">来源: 2. BM25 算法</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">请简述Elasticsearch中评分计算的四个主要步骤。</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Elasticsearch的评分计算过程包括四个步骤：1. 查询解析：将用户请求解析为查询条件；2. 文档检索：找到与条件匹配的文档；3. 评分计算：根据所选算法（如TF-IDF或BM25）为每个文档计算评分；4. 排序：根据评分对文档进行排序并返回结果。</div>
          </div>
          <div class="card-source">来源: 3. ES 评分计算过程</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">当默认评分不满足业务需求时，Elasticsearch提供了哪些方式来自定义评分？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Elasticsearch允许用户通过自定义评分脚本（使用 `script_score` 查询）或自定义评分函数（如 `function_score` 查询）来影响评分计算，从而实现更灵活的评分策略。</div>
          </div>
          <div class="card-source">来源: 4. 自定义评分</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">相比TF-IDF，BM25算法在计算评分时引入了什么关键的改进点？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">BM25算法在评分时考虑了“文档长度的规范化”，这可以有效避免较长的文档仅仅因为其包含的词多而获得不合理的高评分。</div>
          </div>
          <div class="card-source">来源: 2. BM25 算法</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
